package com.yenlien.traceyun.business.controller;


import com.yenlien.traceyun.business.entity.SystemLog;
import com.yenlien.traceyun.business.interceptor.UserAuthUtil;
import com.yenlien.traceyun.business.service.SystemLogService;
import com.yenlien.traceyun.webase.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by LiuSha on 2020/6/10.
 */
@RestController
@RequestMapping("/system/log")
public class SystemLogController extends BaseController {
    @Autowired
    private SystemLogService systemLogService;

    @RequestMapping(value = "/findByList", method = RequestMethod.POST)
    public Object findByList(@RequestBody SystemLog systemLog) {
        systemLog.setCompanyId(UserAuthUtil.getLoginUser().getCompanyId());
        return buildPage(systemLogService.findByList(systemLog));
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    public Object save(@RequestBody SystemLog systemLog) {
        systemLog.setCompanyId(UserAuthUtil.getLoginUser().getCompanyId());
        systemLogService.save(systemLog);
        return success("success");
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Object update(@RequestBody SystemLog systemLog) {
        systemLogService.update(systemLog);
        return success("success");
    }

    @RequestMapping(value = "/findById/{id}", method = RequestMethod.GET)
    public Object findById(@PathVariable String id) {
        return success(systemLogService.findById(id));
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    public Object delete(@PathVariable String id) {
        systemLogService.delete(id);
        return success("success");
    }

}
